"use strict";

// const { city_name } = require("/public/config/config");

// console.log("process.env.NODE_ENV: ", process.env.NODE_ENV);
if (!Array.prototype.indexOf) {
  Array.prototype.indexOf = function (elt) {
    var len = this.length >>> 0;
    var from = Number(arguments[1]) || 0;
    from = from < 0 ? Math.ceil(from) : Math.floor(from);
    if (from < 0) from += len;
    for (; from < len; from++) {
      if (from in this && this[from] === elt) return from;
    }
    return -1;
  };
}
var baseUrl = "/wycms-api";
var yc_duty = {};
function handleResponse(res) {
  yc_duty = res.data;
  var s = "";
  if (["yc"].indexOf(-1)) {
    s += '<span class="container">';
    for (var index = 0; index < yc_duty.length; index++) {
      var item = yc_duty[index];
      s += " <span class=\"item\">\n        <p class=\"name\"> 第".concat(toChineseNumeral(index + 1), "值班人 ").concat(item.dutypeople1, " </p>\n        <span class=\"phone\"> 电话：").concat(item.phone, " </span>\n        <span class=\"tel\"> 手机号：").concat(item.tel, " </span>\n        </span>");
    }
    s += "</span>";
  }
  $("#app").append(s);
}
function getZhiban(name) {
  var query = getQuery();
  $.ajax({
    url: baseUrl + "/customize/duty/indexYc",
    method: "post",
    data: {
      siteId: query.siteId
    },
    success: handleResponse
  });
}
function toChineseNumeral(num) {
  var digits = ["零", "一", "二", "三", "四", "五", "六", "七", "八", "九"];
  var units = ["", "十", "百", "千", "万"];
  var result = "";
  var numStr = String(num);
  for (var i = 0; i < numStr.length; i++) {
    var digit = parseInt(numStr.charAt(i));
    var unit = units[numStr.length - i - 1];
    if (digit === 0 && unit !== "万" && unit !== "") {
      // 如果当前数字是0，并且不是万位或个位，则不需要添加零
      continue;
    }
    result += digits[digit] + unit;
  }
  return result;
}
getZhiban();